package com.zcy.listener;

import com.espertech.esper.common.client.EventBean;
import com.espertech.esper.common.internal.event.map.MapEventBean;
import com.espertech.esper.runtime.client.EPRuntime;
import com.espertech.esper.runtime.client.EPStatement;
import com.espertech.esper.runtime.client.UpdateListener;
import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

@Slf4j
public class PersonListener implements UpdateListener {

    public void update(EventBean[] newData, EventBean[] oldData, EPStatement epStatement, EPRuntime epRuntime) {

        if (newData != null && newData.length > 0) {
            Arrays.asList(newData).forEach(item -> {
                MapEventBean personEventMap = (MapEventBean) item;
                log.info("-NewData：name is {}, age is {}\n", personEventMap.get("name"), personEventMap.get("age"));
            });
        }

    }

}
